package trinidad;

/**
 * Kontroler stanu
 */

public class GameStateX {
	private GameStateX previous;
	private Move madeBy;
	private GameState state;
	public int stValue;
	
	public GameStateX(GameState state) {
		previous = null;
		madeBy = null;
		this.state = state;
	}
	
	public GameStateX() {
		// noop
	}
	
	/**
	 * produces new stateX
	 */
	GameStateX makeState(Move move) {
		GameStateX tmp = new GameStateX();
		tmp.previous = this;
		tmp.madeBy = move;
		tmp.state = this.state.trans(move);
		return tmp;
	}
	
	/**
	 * explains how current state was achieved
	 * @return
	 */
	public ArrayListFX getMoveCascade() {
		ArrayListFX moveList = null;
		if (previous != null) {
			moveList = previous.getMoveCascade();
			moveList.add(madeBy);
		} else moveList = new ArrayListFX();
		return moveList;
	}
	/**
	 * @return Returns the state.
	 */
	public GameState getState() {
		return state;
	}
	/**
	 * @return Returns the madeBy.
	 */
	public Move getMadeBy() {
		return madeBy;
	}
}
